package com.shambles.manage2.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.shambles.manage2.service.SysLogService;
import com.shambles.manage2.tkmapper.entity.MessageRequestVM;
import com.shambles.manage2.tkmapper.entity.RestResponse;
import com.shambles.manage2.tkmapper.entity.SysLog;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;

/**
 * 日志列表接口
 */
@RestController
@RequestMapping("sysLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    /**
     * 日志列表接口
     */
    @PostMapping("log")
    public RestResponse queryLog(@RequestBody JSONObject jsonObject) throws InvocationTargetException, IllegalAccessException {
        MessageRequestVM messageRequestVM=new MessageRequestVM();
        BeanUtils.populate(messageRequestVM,jsonObject);
        PageInfo<SysLog> pageInfo =  sysLogService.queryLog(messageRequestVM);
        return RestResponse.ok(pageInfo);
    }
}
